package com.yxq.mdt.app.modules.socialcontact.presenter;

import com.yxq.mdt.app.base.BasePresenter;
import com.yxq.mdt.app.modules.socialcontact.bean.CommunityCentreBean;
import com.yxq.mdt.app.modules.socialcontact.bean.MainSocialTopBean;
import com.yxq.mdt.app.modules.socialcontact.model.MainSocialContactModel;
import com.yxq.mdt.app.net.ApiModel;

public class MainSocialContactPresenter extends BasePresenter<MainSocialContactContract.View, MainSocialContactModel> implements MainSocialContactContract.Presenter {
    /**
     * 如果当前页面同时需要 Model 层和 View 层,则使用此构造函数(默认)
     *
     * @param rootView
     * @param model
     */
    public MainSocialContactPresenter(MainSocialContactContract.View rootView, MainSocialContactModel model) {
        super(rootView, model);
    }

    @Override
    public void getMaybeInterest() {
        mBaseModel.getMaybeInterest(5, 1, 0, 0, new ApiModel.CommonCallback<MainSocialTopBean>() {
            @Override
            public void onSuccess(MainSocialTopBean mainSocialTopBean) {
                mRootView.onLoadInterestSuccess(mainSocialTopBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadInterestFailed();
            }
        });
    }

    @Override
    public void setInterestRelation(String toUserId, int enabled, int type) {
        mBaseModel.setInterestRelation(toUserId, enabled, type, new ApiModel.CommonCallback<String>() {
            @Override
            public void onSuccess(String s) {
                mRootView.onLoadRelationSuccess(s);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadRelationFailed();
            }
        });
    }

    @Override
    public void getHomeRecommendGroup(String pageSize, String pageNum) {
        mBaseModel.getHomeRecommendGroup(pageSize, pageNum, new ApiModel.CommonCallback<CommunityCentreBean>() {
            @Override
            public void onSuccess(CommunityCentreBean mainSocialTopBean) {
                mRootView.onLoadHomeRecommendSuccess(mainSocialTopBean);
            }

            @Override
            public void onError(String errMsg) {
                mRootView.onLoadHomeRecommendFailed();
            }
        });
    }


}
